<?php

class page {
	var $db;
 	var $smarty;	
	public function __construct($db, $smarty,$page='',$cat='',$product='') {
		$this->db = $db;
		$this->smarty = $smarty;
		$this->page = $page;
		$this->cat = $cat;
		$this->product = $product;
	}
	
	public function main() {
		if($this->page == 'information-contact-us'){
			$this->smarty->assign("ACTIVEMAP", '1');	
		}
		$page = FIN_categoryBean::get_page_by_Url($this->db,$this->page);
		$page->cat_name = str_replace('<br />',' ', $page->cat_name);
		$this->smarty->assign("PATHBG", UPLOAD_FILES);
		$this->smarty->assign("PATHTITLE", $page->cat_name);
		$this->smarty->assign("PAGECONTENT", $page);
		$this->smarty->display("page.tpl");	
	}
	
	public function searchpage() {
		if(isset($_POST['searchtxt']) && $_POST['searchtxt'] != '' && $_POST['searchtxt'] != 'Search ...'){
			
			$countpage = FIN_categoryBean::countCategoryByTypeSearch($this->db,$_SESSION["LC_ALL"],'',$_POST['searchtxt']);
			$link = FOLDER_HOST.$this->page;
			$page['data'] = FIN_categoryBean::getHeaderCategoryByTypeSearch($this->db,$_SESSION['LC_ALL'],MAX_PAGE,"list",'',$_POST['searchtxt']);
			if($page['data']!=""){
				foreach($page['data'] as $item){
					$item->cat_name = str_replace('<br />',' ', $item->cat_name);
				}
			}
			$result = Paging::do_paging($countpage,$page, MAX_PAGE, $link,"?list",'list');
			//echo $countpage;
			$this->smarty->assign("PAGESEARCH", $result);	
		}
		$this->smarty->display("search.tpl");	
	}
	
}
?>
